import { createHashRouter } from "react-router-dom";
import { lazy } from "react";
import NotFound from "@/assets/images/404.png";
import Goods from "@/views/Goods";
const LoginCallback = lazy(() => import("@/views/Login/loginCallback"));
const Layout = lazy(() => import("@/views/Layout"));
const Home = lazy(() => import("@/views/Home/Home"));
const TopCategory = lazy(() => import("@/views/Category/TopCategory/index"));
const SubCategory = lazy(() => import("@/views/Category/SubCategory/index"));
const Login = lazy(() => import("@/views/Login/index"));
const router = createHashRouter([
  {
    path: "/",
    element: <Layout />,
    children: [
      { index: true, element: <Home /> },
      {
        path: "/category/:id",
        element: <TopCategory />,
      },
      {
        path: "/category/sub/:id",
        element: <SubCategory />,
      },
      { path: "/product/:id", element: <Goods /> },
    ],
  },
  { path: "/login", element: <Login></Login> },
  { path: "/login/callback", element: <LoginCallback></LoginCallback> },
  { path: "/*", element: <img src={NotFound}></img> },
]);

export default router;
